# include <bits/stdc++.h>
# define MAXN 100023
# define mid ((l + r) >> 1)
using namespace std;

inline int gn() {
    int k = 0, f = 1;
    char c = getchar();
    for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
    return k * f;
}

struct node {
    int sum;
    node *ls, *rs;
    node() {
        sum = 0;
        ls = rs = NULL;
    }
}*root[MAXN];

node *build(int l, int r) {
    node *x = new node();
    if(l ^ r) {
        x->ls = build(l, mid);
        x->rs = build(mid + 1, r);
    }
    return x;
}

node *add(node *pre, int l, int r, int k) {
    node *x = new node();
    if(l ^ r) {
        if(k <= mid) {
            x->ls = add(pre->ls, l, mid, k);
            x->rs = pre->rs;
        } else {
            x->ls = pre->ls;
            x->rs = add(pre->rs, mid + 1, r, k);
        }
        x->sum = x->ls->sum + x->rs->sum;
    } else x->sum = pre->sum + 1;
    return x;
}

inline int query(node *s, node *t, int l, int r, int k) {
    if(l ^ r) {
        if(k <= t->ls->sum - s->ls->sum) return query(s->ls, t->ls, l, mid, k);
        else return query(s->rs, t->rs, mid + 1, r, k - (t->ls->sum - s->ls->sum));
    } else return l;
}

int n, m, data[MAXN], a[MAXN], hs[MAXN], maxa = -0x7fffffff, mina = 0x7fffffff, tot;

inline int search(int x) {
    int l = 1, r = n;
    while(l + 1 < r) {
        if(x <= hs[mid]) r = mid;
        else l = mid;
    }
    return hs[l] == x ? l : r;
}

int main() {
    //freopen("in.txt", "r", stdin);
    freopen("kth.in", "r", stdin);
    freopen("kth.out", "w", stdout);
    n = gn();
    m = gn();
    for(int i = 1;  i <= n; i++) {
        maxa = max(maxa, data[i] = a[i] = gn());
        mina = min(mina, a[i]);
    }
    sort(a + 1, a + 1 + n);
    for(int i = 1; i <= n; i++) {
        if(a[i] != a[i - 1]) {
            hs[++tot] = a[i];
        }
    }
    root[0] = build(1, tot);
    for(int i = 1; i <= n; i++) {
        root[i] = add(root[i - 1], 1, tot, search(data[i]));
    }
    int s, t, k;
    while(m--) {
        s = gn();
        t = gn();
        k = gn();
        printf("%d\n", hs[query(root[s - 1], root[t], 1, tot, k)]);
    }
}
